use std::{borrow::Cow, process::Command};

use crate::constant::UNKNOWN_RUST_VERSION;

#[warn(dead_code)]
pub fn exit(code: i32){
    std::process::exit(code);
}

pub fn get_rust_current_version<'a>() -> Cow<'static,str> {
    let output = Command::new("rustc")
        .arg("--version")
        .output();
    if let Ok(out) = output && let Ok(v) = String::from_utf8(out.stdout){
        return Cow::Owned(v);
    }
    Cow::Borrowed(UNKNOWN_RUST_VERSION)
}